//配置数据库

const mysql = require("mysql");

const mysqlcon = mysql.createConnection({host:"127.0.0.1",port:"3306",user:"root",password:"root",database:"mydb"});

mysqlcon.connect();

function toQuery(sql)
{
    return new Promise((resolve,reject)=>{
        mysqlcon.query(sql,(err,data)=>{
            if(err)
            {
                resolve([false,"查询错误"])
            }
            else
            {
                resolve([true,data]);
            }
        })
    })
}

module.exports = toQuery;